<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ include file="../common/taglibs.jsp"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="${rootPath}/css/a.css" type="text/css" rel="stylesheet" />
<link href="${rootPath}/css/index.css" type="text/css" rel="stylesheet" />
<link href="${rootPath}/css/common.css" type="text/css" rel="stylesheet" />
<title>云商宝终端SN查询</title>

<script type="text/javascript"
	src="<s:url value="/js/jquery-1.3.2.js" />"></script>
<script type="text/javascript" src="<s:url value="/js/common.js" />"></script>
<script language="javascript" type="text/javascript"
	src="<s:url value="/js/My97DatePicker/WdatePicker.js"/>"></script>
<script type='text/javascript' src='<s:url value="/dwr/engine.js"/>'></script>
<script type='text/javascript' src='<s:url value="/dwr/interface/MccQuery.js"/>'></script>
<script type="text/javascript">
$(document).ready(function(){

      loadBrandCode();

      var orgCode=$("#orgCode").val();
      if(orgCode != ''){
     
      }

      $("#sub").click(function(){
         if(!checkDate()){
         	return false;
         }
         $("#importForm").attr("action","<%=basePath%>/ysbTermSn/queryTermSn.ct");
		 $("#importForm").submit();
       
      });
      
      $("#szPower").click(function() {
          if(!checkDate()){
           	return false;
           }
		 $("#importForm").attr("action","<%=basePath%>/ysbTermSn/excelTermSn.ct");
		 $("#importForm").submit();
	   });				
      
   });

   function loadOCode(){
        var orgCode = $("#orgCode").val();
		if (!orgCode) {
			return;
		}
		
		MccQuery.loadOCode(orgCode, function(sortSmall) {
			fillSelect_sort("accountNo", sortSmall);
		});
   }
   
   	//加载终端名称
	function loadBrandCode() {
	
			var sortCode = $("#posBrand").val();
			 var posName = $("#posName").val();
			
			if (sortCode==null||sortCode=="") {
				return;
			}
			
			MccQuery.loadYsbBrandNameByCode(sortCode, function(sortSmall) {
				fillSelect_sort("posName", sortSmall,posName,sortCode);
			});
		}
	
	function fillSelect_sort(sid, address,choiseId,sortCode) {
				if (!address || !sid) {
					return;
				}
				var $select = $("#" + sid);
				$select.empty();
				
				$("#" + sid).empty().append("<option value='-1'>不限</option>");
				
		        var selModelCode = $("#selModelCode").val();
		        var oldBandCode = $("#oldBandCode").val();
			   
				for ( var i = 0; i < address.length; i++) {
			        var selStr = "";
					if(selModelCode != null && selModelCode != '' && address[i].CODE == selModelCode && sortCode == oldBandCode){
						selStr = " selected='selected' ";
					}
					$select.append("<option " + selStr + " value='"+address[i].CODE+"'>"+ address[i].NAME + "</option>");
				}
				
			
		}


	function   str2date(str){
		var d=null;   
		var reg=/^(\d{4})(\d{2})(\d{2})$/  ;
			if(arr=str.match(reg))d=new   Date(Number(arr[1]),Number(arr[2])-1,Number(arr[3])) ; 
		return   d;   
	}  

	function  checkDate(){ 
		var endTime = $("#endActDate").val();
		var beginTime = $("#startActDate").val();
		
		if( (!endTime && beginTime) || (endTime && !beginTime) ){
			alert("起始时间范围必须选择!");
			return false;
		} else if ( (!endTime && !beginTime) ) {
			return true;
		}/* 
		var date1=str2date(beginTime);
		var date2=str2date(endTime);
			
		if(date1.getMonth()!=date2.getMonth()){
		    alert("选择的起始时间不在同一个月内！");
			return false;
		} */
		return true;
	}
</script>
</head>
<body>
<table class="tb">
    <tbody>
		<s:form id="importForm" action="queryTermSn.ct" method="post"
			namespace="/ysbTermSn"  theme="simple">
			
        <tr class="tb-line">
            <td class="tb-td" colspan="6"><div class="tb-h2">POS收单运营管理平台</div></td>
        </tr>

        <tr class="tb-line">
            <td class="tb-td" colspan="6"><div class="tb-h3">云商宝终端SN查询</div></td>
        </tr>
		<tr class="tb-line">
			<td width="12%" style="min-width: 150px" align="right" class="tb-td">
		                <div class="tb-h4">终端序列号：</div>
		   </td>
					<td class="tb-td" >
		                <label class="tb-input-normal">
							<s:textfield id="serialNum" name="searchCondition.serialNum" cssClass="queryWidth" />
						</label>
                	</td>
		            <td width="12%" style="min-width: 150px" align="right" class="tb-td">
		                <div class="tb-h4">所属代理商：</div>
		            </td>
					<td class="tb-td" >
		                <label class="tb-input-normal">
		                	<s:textfield id="realName" name="searchCondition.realName" cssClass="queryWidth" />
		                </label>
					</td>
					 <s:if test="#session.session_merchant.roleType==\"03\"||#session.session_merchant.roleType==\"15\" || #session.session_merchant.roleType==\"16\"">
					  <td align="right" width="15%"></td>
					  <td class="tb-td">
		                  <s:hidden name="searchCondition.orgCode" value="%{#session.session_merchant.orgCode}" id="orgCode" />
					  </td>
					</s:if>	
					<s:else>
		            <td width="12%" style="min-width: 150px" align="right" class="tb-td">
		                <div class="tb-h4">所属机构：</div>
		            </td>
					<td class="tb-td">
                		<label class="tb-select">
							<s:select cssClass="queryWidth" name="searchCondition.orgCode" id="orgCode"
								list="orgList" listKey="InsIdCd" listValue="InsName"/>
                		</label>
					</td>
					</s:else>
				</tr>
				

				<tr class="tb-line">
			            <td align="right" class="tb-td">
			                <div class="tb-h4">品牌：</div>
			            </td>
						<td class="tb-td">
	                		<label class="tb-select">
								<s:select cssClass="queryWidth" name="searchCondition.posBrand"
									id="posBrand" onchange="loadBrandCode()"
									list="#request.brandMap" listKey="key" listValue="value"  headerKey="-1" headerValue="不限"/>
               				</label>
						</td>
			            <td align="right" class="tb-td">
			                <div class="tb-h4">型号：</div>
			            </td>
						<td class="tb-td">
	                		<label class="tb-select">
							
								<s:select label="01"  cssClass="queryWidth" name="searchCondition.posName"
									id="posName"
									list="#request.nameMap" listKey="key" listValue="value"  headerKey="-1" headerValue="不限"/>
								
								<s:hidden id="selModelCode" name="#request.selModelCode"  />
								<s:hidden id="oldBandCode" name="#request.oldBandCode"  />
						
               				</label>
						</td>
						
			            <td align="right" class="tb-td">
			                <div class="tb-h4">机型：</div>
			            </td>
						<td class="tb-td">
	                		<label class="tb-select">
								<s:select cssClass="queryWidth" name="searchCondition.posType"
									id="orgCode"
									list="#request.typeMap" listKey="key" listValue="value" headerKey="-1" headerValue="不限"/>
               				</label>
						</td>
				</tr>
				<tr class="tb-line">
			            <td align="right" class="tb-td">
			                <div class="tb-h4">是否已绑定：</div>
			            </td>
			            <td class="tb-td">
			                <label class="tb-select">
								<s:select cssClass="queryWidth" name="searchCondition.isBind"
									id="isBind"  
									list="#{'99':'不限','Y':'是','N':'否'}"/>
               				</label>
						</td>
			            <td align="right" class="tb-td">
			                <div class="tb-h4">是否已出库：</div>
			            </td>
					   <td class="tb-td">
                			<label class="tb-select">
								<s:select cssClass="queryWidth" name="searchCondition.isUsed"
									id="isUsed"  
									list="#{'99':'不限','Y':'是','N':'否'}"/>
                		</label>
						</td>
						
			            <td align="right" class="tb-td">
			                <div class="tb-h4">入网方式：</div>
			            </td>
						<td class="tb-td">
	                		<label class="tb-select">
								<s:select cssClass="queryWidth" name="searchCondition.netInType"
									id="netInType"
									list="#request.netInTypeMap" listKey="key" listValue="value" headerKey="-1" headerValue="不限"/>
               				</label>
						</td>
				</tr>
				<tr class="tb-line">
						
			            <td align="right" class="tb-td">
			                <div class="tb-h4">是否已刷288交易：</div>
			            </td>
						<td class="tb-td">
	                		<label class="tb-select">
								<s:select cssClass="queryWidth" name="searchCondition.useType"
									id="useType"
									list="#request.use288Map" listKey="key" listValue="value" headerKey="-1" headerValue="不限"/>
               				</label>
						</td>
						
						
			            <td align="right" class="tb-td">
			                <div class="tb-h4">是否直属：</div>
			            </td>
						<td class="tb-td">
	                		<label class="tb-select">
								<s:select cssClass="queryWidth" name="searchCondition.ysbIsDirectly"
									id="ysbIsDirectly"
									list="#request.ysbIsDirectlyMap" listKey="key" listValue="value" headerKey="-1" headerValue="不限"/>
               				</label>
						</td>
						<td width="12%" style="min-width: 150px" align="right" class="tb-td">
							<div class="tb-h4">激活日期：</div>
						</td>
						<td class="tb-td" >
							<label class="tb-input-mini">
								<s:textfield id="startActDate" name="searchCondition.startActDate" onFocus="WdatePicker({dateFmt:'yyyyMMdd',readOnly:true,wdate:true,errDealMode:0});"
									theme="simple" cssClass="queryWidth" /> 
							</label>至：
							<label class="tb-input-mini">
								<s:textfield id="endActDate" name="searchCondition.endActDate" onFocus="WdatePicker({dateFmt:'yyyyMMdd',readOnly:true,wdate:true,errDealMode:0});"
									theme="simple" cssClass="queryWidth" />
							</label>
						</td>
				</tr>
				<tr>
					<td colspan="6">&nbsp;</td>
				</tr>
				<tr>
					<td colspan="6" align="center"><div style="color: blue;">
							<s:actionmessage />
						</div>
						<div style="color: red;">
							<s:actionerror />
						</div>
					</td>
				</tr>

				<tr class="tb-line">
					<td class="tb-td line-submit" align="right" colspan="6">
                		<label class="tb-input-submit">
					 		<input type="button" value="查询" id="sub"/>
		                </label>
		                <label class="tb-input-submit">
				             <s:reset value="取  消" />
		                </label>
						   <s:if test="#request.searchRsList != null && #request.searchRsList.size>0">
								
				                <label class="tb-input-submit">
									<input id="szPower" type="submit" value="导出Excel" />
				                </label>
					       </s:if>
						   <s:else>
						   
			                <label class="tb-input-submit">
								<input id="szPower" disabled="disabled" value="导出Excel" type="submit" />
			                </label>
					       </s:else>
							</td>
				</tr>
			<table width="100%" cellpadding="0" cellspacing="0" border="0">
				<s:if  test="#request.searchRsList != null && #request.searchRsList.size>0">
					<tr class="tb-line">
						<td class="tb-td paging" colspan="12" align="left">&nbsp;&nbsp;&nbsp;&nbsp; <page:pageCount
								max_pages="11" totalPage="${requestScope.totalPage}"
								currentPage="${requestScope.currentPage}"
								action="${rootPath}/ysbTermSn/queryTermSn.ct?currentPage=" />

						</td>
					</tr>
					</s:if>
			</table> 
		</s:form>
    </tbody>
</table>
<div class="big-tb">
    <table class="tb" style="width: 160%;">
				<thead>
		            <tr class="tb-line">
		                <th class="tb-th" colspan="16">终端SN信息列表</th>
		            </tr>
					<tr class="tb-line bg-gray">
					    <th class="tb-th">终端序列号</th>
						<th class="tb-th">商户号</th>
						<th class="tb-th">商户名称</th>
						<th class="tb-th">手机号</th>
						<th class="tb-th">注册日期</th>
						<th class="tb-th">终端号</th>
						<th class="tb-th">所属代理商</th>
						<th class="tb-th">品牌</th>
						<th class="tb-th">型号</th><%-- 
						<th class="tb-th">机型</th>
						 <s:if test="#session.session_merchant.roleType!=\"03\" && #session.session_merchant.roleType!=\"15\" && #session.session_merchant.roleType!=\"16\"">
						    <th class="tb-th">所属机构</th>
						 </s:if> --%>
						<th class="tb-th">等级</th>
						<th class="tb-th">是否已绑定</th>
						<th class="tb-th">是否已出库</th>
						<th class="tb-th">是否有效</th>
						<th class="tb-th">激活时间</th><!-- 
						<th class="tb-th">备注</th> -->
						<th class="tb-th">入库时间</th>
						<th class="tb-th">出库时间</th>
					</tr>
				</thead>
				<tbody>
					<s:iterator value="#request.searchRsList" status="stat" id="term">
						<tr class="tb-line">
							<td class="tb-td" align="center">
							 <s:property value="#term.serialNum"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.mercCode"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.mchtName"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.phone"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.mchtCrtDateStr"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.termCode"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.agentName"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.posBrand"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.posName"/>
							</td><%-- 
							<td class="tb-td" align="center">
							 <s:property value="#term.posType"/>
							</td>
							 <s:if test="#session.session_merchant.roleType!=\"03\" && #session.session_merchant.roleType!=\"15\" && #session.session_merchant.roleType!=\"16\"">
						       <td class="tb-td" align="center">
								 <s:property value="#term.orgName"/>
								</td>
						     </s:if>
							 --%>
							<td class="tb-td" align="center">
							 <s:property value="#term.snClass"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.isBind"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.isUsed"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.tekId"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.actDateStr"/>
							</td><%-- 
							<td class="tb-td" align="center">
							 <s:property value="#term.remark"/>
							</td> --%>
							<td class="tb-td" align="center">
							 <s:property value="#term.inDateStr"/>
							</td>
							<td class="tb-td" align="center">
							 <s:property value="#term.outDateStr"/>
							</td>
						</tr>
						</s:iterator>
				</tbody>
    </table>
</div>
</body>
</html>